<?php require_once('../Connections/administracion_peluvets.php'); ?>
<?php
if (!function_exists("GetSQLValueString")) {
function GetSQLValueString($theValue, $theType, $theDefinedValue = "", $theNotDefinedValue = "") 
{
  $theValue = get_magic_quotes_gpc() ? stripslashes($theValue) : $theValue;

  $theValue = function_exists("mysql_real_escape_string") ? mysql_real_escape_string($theValue) : mysql_escape_string($theValue);

  switch ($theType) {
    case "text":
      $theValue = ($theValue != "") ? "'" . $theValue . "'" : "NULL";
      break;    
    case "long":
    case "int":
      $theValue = ($theValue != "") ? intval($theValue) : "NULL";
      break;
    case "double":
      $theValue = ($theValue != "") ? "'" . doubleval($theValue) . "'" : "NULL";
      break;
    case "date":
      $theValue = ($theValue != "") ? "'" . $theValue . "'" : "NULL";
      break;
    case "defined":
      $theValue = ($theValue != "") ? $theDefinedValue : $theNotDefinedValue;
      break;
  }
  return $theValue;
}
}

$editFormAction = $_SERVER['PHP_SELF'];
if (isset($_SERVER['QUERY_STRING'])) {
  $editFormAction .= "?" . htmlentities($_SERVER['QUERY_STRING']);
}

if ((isset($_POST["MM_insert"])) && ($_POST["MM_insert"] == "insertar")) {
  $insertSQL = sprintf("INSERT INTO usuario (rut, nombre, apellido_pat, apellido_mat, telefono, direccion, nom_perfil, clave) VALUES (%s, %s, %s, %s, %s, %s, %s, %s)",
                       GetSQLValueString($_POST['rut'], "text"),
                       GetSQLValueString($_POST['nombre'], "text"),
                       GetSQLValueString($_POST['apellido_pat'], "text"),
                       GetSQLValueString($_POST['apellido_mat'], "text"),
                       GetSQLValueString($_POST['telefono'], "int"),
                       GetSQLValueString($_POST['direccion'], "text"),
                       GetSQLValueString($_POST['nom_perfil'], "text"),
                       GetSQLValueString($_POST['clave'], "int"));

  mysql_select_db($database_administracion_peluvets, $administracion_peluvets);
  $Result1 = mysql_query($insertSQL, $administracion_peluvets) or die(mysql_error());

  $insertGoTo = "usuarios.php";
  if (isset($_SERVER['QUERY_STRING'])) {
    $insertGoTo .= (strpos($insertGoTo, '?')) ? "&" : "?";
    $insertGoTo .= $_SERVER['QUERY_STRING'];
  }
  header(sprintf("Location: %s", $insertGoTo));
}
?>
<?php require_once('../conexion.php'); ?>
<?php
    include "../conexion.php"; 
if (isset($_POST ['rut']['nombre']['apellido_pat']['apellido_mat']['telefono']['direccion']['nom_perfil']['clave'])) mysql_query("INSERT INTO usuario (rut, nombre, apellido_pat,apellido_mat, telefono, direccion, nom_perfil, clave) VALUES ('".$_POST['rut']."','".$_POST['nombre']."','".$_POST['apellido_pat']."','".$_POST['apellido_mat']."','".$_POST['telefono']."','".$_POST['direccion']."','".$_POST['nom_perfil']."','".$_POST['clave']."')") or die(mysql_error()); ?> 

    <html xmlns="http://www.w3.org/1999/xhtml">
<head>
	<meta http-equiv="Content-type" content="text/html; charset=utf-8" />
	<title>Usuarios</title>
    <link rel="stylesheet" href="../css/jquery.ui.all.css">
<link rel="stylesheet" href="../css/demos.css">
<link rel="stylesheet" href="../css/jquery.ui.datepicker.css">
<link rel="stylesheet" href="css/jquery-ui-1.8.20.custom.css">
<script src="js/jquery-1.7.2.min.js"></script>
<script src="js/jquery-ui-1.8.20.custom.min.js"></script>
<script src="ui/jquery.ui.core.js"></script>
	<script src="ui/jquery.ui.widget.js"></script>
	<script src="ui/jquery.ui.datepicker.js"></script>
	<script src="SpryAssets/SpryValidationTextField.js" type="text/javascript"></script>
<script>
	$(function() {
		$( "#calendario" ).datepicker();
	});
	</script>
    
    
    <script type="text/javascript" src="JSS/marimonquery.js"></script>
<script type="text/javascript">



</script>
	<link rel="stylesheet" href="../css/style.css" type="text/css" media="all" />
    <style type="text/css">
<!--
.Estilo1 {color: #000080}
.Estilo2 {
	font-size: 36px;
	font-family: Geneva, Arial, Helvetica, sans-serif;
	font-weight: bold;
}
-->
    </style>
    <link href="SpryAssets/SpryValidationTextField.css" rel="stylesheet" type="text/css">
</head>
<body>
<!-- Header -->
<div id="templatemo_header_wrapper">

	<div id="templatemo_header">
    <div class="inner">
	 <h3><a href="../moduloA.php"><strong>Volver</strong></a></h3>

          <!--<h1 class="logo"><a href="">Clinica Veterinaria</a></h1>-->
		
	</div>
	</div>
	</div>
<div class="fright">
<div id="templatemo_content_wrapper">
	
        <table width="1080" height="611">
          <tr><td width="442" height="593">
<div id="header">

		</div>
		<!-- End Logo + Top Nav -->
		
		<!-- Main Nav -->
		<div id="navigation">
		
		</div>
		<!-- End Main Nav -->
	

<!-- End Header -->

<!-- Container -->
<div id="container">
	<div class="shell1">
		
		<!-- Small Nav -->
		<div class="small-nav"></div>
		<!-- End Small Nav -->
		
		<!-- Message OK -->
	  <!-- End Message OK -->		
		
	  <!-- Message Error -->
	  <!-- End Message Error -->
  <br />
		<!-- Main -->
		<div id="main">
        
        
        
        
			<div class="cl"></div>
			
			<!-- Content -->
			<div id="manten1">
				
				<!-- Box -->
				<div class="box">
					<!-- Box Head -->
					<div class="box-head3"> 
						<h2 class="left">Registro de usuarios&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; </h2>
<div class="right">

                            
						</div>
					</div>
					<!-- End Box Head -->	
                     
    <div class="table">
<form action="<?php echo $editFormAction; ?>" id="insertar" name="insertar" method="POST">
        <table width="307">
        <tr><th colspan="2"><span class="Estilo1"><h3 align="center">Insertar Registro</h3></span></th>
       </tr>
        <tr>
        <td  ><span class="Estilo1">Rut</span></td>
        <td width="209"><span id="sprytextfield1">
          <input type="text" name="rut" id="rut" class="field size">
          <span class="textfieldRequiredMsg">Obligatorio</span></span></input></td>
       
        <td><span class="Estilo1">Nombre </span></td>
        <td width="209"><span id="sprytextfield2">
          <input type="text" name="nombre" id="nombre" class="field size">
          <span class="textfieldRequiredMsg">Obligatorio</span></span>          </input></td>
        </tr>
        
                <tr>
        <td  ><span class="Estilo1">Apellido Paterno</span></td>
        <td width="209"><span id="sprytextfield3">
          <input type="text" name="apellido_pat" id="apellido_pat" class="field size">
          <span class="textfieldRequiredMsg">Obligatorio</span></span>          </input></td>
        
        <td  ><span class="Estilo1">Apellido Materno</span></td>
        <td width="209"><span id="sprytextfield3">
          <input type="text" name="apellido_mat" id="apellido_mat" class="field size">
          <span class="textfieldRequiredMsg">Obligatorio</span></span>          </input></td>
        </tr>
                <tr>
        <td  ><span class="Estilo1">Telefono</span></td>
        <td width="209"><span id="sprytextfield4">
          <input type="text" name="telefono" id="telefono" class="field size">
          <span class="textfieldRequiredMsg">Obligatorio</span></span>          </input></td>
       
        <td  ><span class="Estilo1">Dirección</span></td>
        <td width="209"><span id="sprytextfield5">
        <input type="text" name="direccion" id="direccion" class="field size">
        <span class="textfieldRequiredMsg">Obligatorio</span></span>          </input></td>
        </tr>
            
                <tr>
        <td  ><span class="Estilo1">Tipo de Usuario</span></td>
        <td width="209"><select name="nom_perfil" id="nom_perfil">
          <option value="seleccionar">seleccionar</option>
          <option value="administrador">Administrador</option>
          <option value="veterinario">Veterinario</option>
		  <option value="secretaria">Secretaria</option>
        </select></td>
       
        <td  ><span class="Estilo1">Clave</span></td>
        <td width="209"><span id="sprytextfield7">
          <input type="password" name="clave" id="clave" class="field size">
          <span class="textfieldRequiredMsg">Obligatorio</span></span>          </input></td>
        </tr>
        
        <tr>
        <td></td>
        <td> <input type="submit" name="Submit" class="button" value="Insertar Registro" />        </td>
        </tr>
        </table>  
        
        <input type="hidden" name="MM_insert" value="insertar">
    </form>
	</div>
</div>
</div>
</div>
</div>
</div>
                     
                     <?php

   $result=mysql_query("SELECT * FROM usuario ORDER BY id_usuario ASC;"); 
?>
			      </p>
			     <div class="table">
                     <table width="85%" border="0" cellspacing="0" cellpadding="0">
							<tr>
                            <th width="178"><div align="left">Codigo</div></th>
							 <th width="178"><div align="left">Rut</div></th>
                             <th width="178"><div align="left">Nombre</div></th>
                             <th width="178"><div align="left">Apellido Materno</div></th>
							 <th width="178"><div align="left">Apellido Paterno</div></th>
                             <th width="178"><div align="center">Telefono</div></th>
                             <th width="178"><div align="left">Direccion</div></th>
                             <th width="178"><div align="center">Perfil</div></th>
                             <th width="178"><div align="left">Clave</div></th>
                             <th width="104" class="ac"><div align="center">Eliminar</div></th>
				   </tr>
                           <?
   while($row = mysql_fetch_array($result)) { 
      print("<tr><td><center>".$row['id_usuario']."</center></td>
	              <td>".$row['rut']."</td>
			      <td>".$row['nombre']."</td>
				  <td>".$row['apellido_pat']."</td>
				  <td>".$row['apellido_mat']."</td>
				  <td>".$row['telefono']."</td>
				  <td>".$row['direccion']."</td>
				  <td>".$row['nom_perfil']."</td>
				  <td><center>".$row['clave']."</center></td>
				  <td><a href='usuarios.php?id_usuario=".$row['id_usuario']."' class='ico del'>Eliminar</a></td></tr>");
				  
   } 
   mysql_free_result($result); 
    
   include("../conexion.php");  
   $id_usuario=$_GET['id_usuario']; 
   mysql_query("delete from usuario where id_usuario = $id_usuario"); 
    
?> 
    </table>  
    
    </div>    
						<!-- Pagging -->
						
				</div>
	  </div>
	</div>
</div>
<div id="fin">
	<div class="shell1">
 
                     
     
    
    
    <div id="sidebar">
				
				<!-- Box -->
				<div class="box">
					
					<!-- Box Head -->
					<!-- End Box Head-->
					
					<div class="box-content">
    
   
</div>
</div>
</div>
</div>
</div>
</div>
</table>
</div>
</div>
                    <script type="text/javascript">
<!--
var sprytextfield1 = new Spry.Widget.ValidationTextField("sprytextfield1");
var sprytextfield2 = new Spry.Widget.ValidationTextField("sprytextfield2");
var sprytextfield3 = new Spry.Widget.ValidationTextField("sprytextfield3");
var sprytextfield4 = new Spry.Widget.ValidationTextField("sprytextfield4");
var sprytextfield5 = new Spry.Widget.ValidationTextField("sprytextfield5", "email");
var sprytextfield6 = new Spry.Widget.ValidationTextField("sprytextfield6", "phone_number", {format:"phone_custom"});
var sprytextfield7 = new Spry.Widget.ValidationTextField("sprytextfield7");
//-->
</script>
</body>
</html>
    